#pragma once
#include <windows.h>

class Bitmap
{
public:
    Bitmap ()
        : _hBitmap (0)
    {}
    // Transfer semantics
    Bitmap (Bitmap & bmp)
        : _hBitmap (bmp.Release ())
    {}
    void operator = (Bitmap & bmp)
    {
        if (bmp._hBitmap != _hBitmap)
        {
            Free ();	
            _hBitmap = bmp.Release ();
        }
    }
    HBITMAP Release ()
    {
        HBITMAP h = _hBitmap;
        _hBitmap = 0;
        return h;
    }
    ~Bitmap ()
    {
        Free ();
    }
    // implicit conversion for use with Windows API
    operator HBITMAP () { return _hBitmap; }

	void Load(HINSTANCE, char const *);
	void Load(HINSTANCE, int);
	void Load(char *);
	void GetSize(int &, int &);
protected:
    Bitmap (HBITMAP hBitmap)
        : _hBitmap (hBitmap)
    {}
    void Free ()
    {
        if (_hBitmap) 
            ::DeleteObject (_hBitmap);
    }

    HBITMAP    _hBitmap;
};